package com.example.rabbitmq.sender;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Copyright(C), 2020-2021, AmbroseCdMeng
 * FileName:    FanoutSender
 * Author:      AmbroseCdMeng
 * Date:        2021/3/2 13:51
 * Description: 编写发送者。实现广播模式
 * History:
 * <author>     <time>      <version>       <desc>
 * 作者姓名     修改时间        版本号           描述
 */
@Component
public class FanoutSender {
    @Autowired
    private AmqpTemplate rabbitTemplate;
    public void send() throws Exception{
        String context = "Fanout";
        System.out.println("Sender" + context);
        this.rabbitTemplate.convertAndSend("fanoutExchange", "", context);
    }
}
